package com.himore.api.web.controller.modules;

import java.util.List;

import com.himore.api.web.model.TWeekTaskInfo;
import com.himore.api.web.service.ITWeekTaskInfoService;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.himore.api.common.annotation.Log;
import com.himore.api.common.core.controller.BaseController;
import com.himore.api.common.core.domain.AjaxResult;
import com.himore.api.common.enums.BusinessType;

import com.himore.api.common.utils.poi.ExcelUtil;
import com.himore.api.common.core.page.TableDataInfo;

/**
 * 任务信息Controller
 * 
 * @author ruoyi
 * @date 2021-01-21
 */
@Api(tags = "周任务信息管理")
@RestController
@RequestMapping("/system/weektask")
public class TWeekTaskInfoController extends BaseController
{
    @Autowired
    private ITWeekTaskInfoService tWeekTaskInfoService;

    /**
     * 查询任务信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWeekTaskInfo tWeekTaskInfo)
    {
        startPage();
        List<TWeekTaskInfo> list = tWeekTaskInfoService.selectTWeekTaskInfoList(tWeekTaskInfo);
        return getDataTable(list);
    }

    /**
     * 导出任务信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "任务信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TWeekTaskInfo tWeekTaskInfo)
    {
        List<TWeekTaskInfo> list = tWeekTaskInfoService.selectTWeekTaskInfoList(tWeekTaskInfo);
        ExcelUtil<TWeekTaskInfo> util = new ExcelUtil<TWeekTaskInfo>(TWeekTaskInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取任务信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
    {
        return AjaxResult.success(tWeekTaskInfoService.selectTWeekTaskInfoById(taskId));
    }

    /**
     * 新增任务信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "任务信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWeekTaskInfo tWeekTaskInfo)
    {
        return toAjax(tWeekTaskInfoService.insertTWeekTaskInfo(tWeekTaskInfo));
    }

    /**
     * 修改任务信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "任务信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWeekTaskInfo tWeekTaskInfo)
    {
        return toAjax(tWeekTaskInfoService.updateTWeekTaskInfo(tWeekTaskInfo));
    }

    /**
     * 删除任务信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "任务信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(tWeekTaskInfoService.deleteTWeekTaskInfoByIds(taskIds));
    }
}
